package com.epfly.iface.promo.activity.enums;

import com.google.common.collect.Maps;

import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 适用星期：0.不限;1.周一;2.周二;3.周三;4.周四;5.周五;6.周六;7.周日
 */
public enum EffectiveDaysEnum {

    UN_LIMIT((byte) 0, "不限"),
    MON((byte) 1, "周一"),
    TUE((byte) 2, "周二"),
    WEB((byte) 3, "周三"),
    THU((byte) 4, "周四"),
    FRI((byte) 5, "周五"),
    SAT((byte) 6, "周六"),
    SUN((byte) 7, "周日"),
    ;

    private final Byte key;

    private final String value;


    EffectiveDaysEnum(Byte key, String value) {
        this.key = key;
        this.value = value;
    }

    public Byte getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    private static final Map<Byte, EffectiveDaysEnum> loopUp = Maps.newHashMap();

    static {
        for (EffectiveDaysEnum value : values()) {
            loopUp.put(value.getKey(), value);
        }
    }
    public static String getValue(Collection<Byte> keyList) {
        return keyList.stream().map(e -> loopUp.get(e).getValue()).collect(Collectors.joining("、"));
    }
}
